***EP election regressions

**Prepare data

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\new\allwaves_new.dta"

replace female_MA = female if surveyname == "MAPLE1"
drop female 

keep if surveyname == "EB2" | surveyname == "MAPLE2"

gen female = female_MA
replace female = female_eb if surveyname == "EB2"
label var female "Female"

gen age = .
replace age = 0 if agegroup1_MA==1 | agegroup1_ess==1 | agegroup1_eb==1
replace age = 0.5 if agegroup2_MA==1 | agegroup2_ess==1 | agegroup2_eb==1
replace age = 1 if agegroup3_MA==1 | agegroup3_ess==1 | agegroup3_eb==1
label var age "Age"

replace edu_EB = . if edu_EB <8

foreach v of varlist edu_MA edu_EB {
    qui summ `v'
    gen `v'2 = (`v' - r(min)) / (r(max) - r(min))
}

gen education = .
replace education = edu_MA2 if surveyname == "MAPLE2"
replace education = edu_EB2 if surveyname == "EB2"
label var education "Education"

recode economy_nat_MA (88=.)
recode economy_nat_MA (1=5) (2=4) (3=3) (4=2) (5=1)

recode econ_eval_EB (5=.)
recode econ_eval_EB (1=5) (2=4) (4=2) (5=1)

foreach v of varlist economy_nat_MA econ_eval_EB {
    qui summ `v'
    gen `v'2 = (`v' - r(min)) / (r(max) - r(min))
}

gen econ_eval = economy_nat_MA2
replace econ_eval = econ_eval_EB2 if surveyname == "EB2"
label var econ_eval "Economy"

tab leftright_MA
recode leftright_MA (88 = .)
tab leftright_EB
recode leftright_EB (97 = .)

foreach v of varlist leftright_MA leftright_EB {
    qui summ `v'
    gen `v'2 = (`v' - r(min)) / (r(max) - r(min))
}

gen leftright = leftright_MA2
replace leftright = leftright_EB2 if surveyname == "EB2"
label var leftright "Left-right"

gen weight = weight_rim_MA
replace weight = weight_EB if surveyname == "EB2"
label var weight "Weight all"

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\new\elections.dta", replace

*Belgium

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\new\elections.dta"
keep if country == "Belgium"

gen survey_online = 0
replace survey_online = 1 if surveyname == "MAPLE2"
label var survey_online "Online survey"

gen turnout_MA = .
replace turnout_MA = 0 if voted_eu_MA > 1 & voted_eu_MA != .
replace turnout_MA = 1 if voted_eu_MA == 1

gen turnout_EB = .
replace turnout_EB = 0 if voted_eu_EB > 1 & voted_eu_EB != .
replace turnout_EB = 1 if voted_eu_EB == 1

gen turnout = turnout_MA
replace turnout = turnout_EB if surveyname == "EB2"
label var turnout "Turnout"

*Maple

gen vote_valid_MA = .
replace vote_valid_MA = 0 if votechoice_eu_MA <= 66

gen vote_nva_MA = vote_valid_MA
replace vote_nva_MA = 1 if votechoice_eu_MA == 6

gen vote_vb_MA = vote_valid_MA
replace vote_vb_MA = 1 if votechoice_eu_MA == 13

gen vote_cd_MA = vote_valid_MA
replace vote_cd_MA = 1 if votechoice_eu_MA == 1 | votechoice_eu_MA == 11

gen vote_so_MA = vote_valid_MA
replace vote_so_MA = 1 if votechoice_eu_MA == 5 | votechoice_eu_MA == 12

gen vote_gr_MA = vote_valid_MA
replace vote_gr_MA = 1 if votechoice_eu_MA == 2 | votechoice_eu_MA == 7

gen vote_li_MA = vote_valid_MA
replace vote_li_MA = 1 if votechoice_eu_MA == 4 | votechoice_eu_MA == 8

gen vote_rl_MA = vote_valid_MA
replace vote_rl_MA = 1 if votechoice_eu_MA == 10

*EB

gen vote_valid_EB = .
replace vote_valid_EB = 0 if party_voted_eu_EB <= 17

gen vote_nva_EB = vote_valid_EB
replace vote_nva_EB = 1 if party_voted_eu_EB == 1

gen vote_vb_EB = vote_valid_EB
replace vote_vb_EB = 1 if party_voted_eu_EB == 2

gen vote_cd_EB= vote_valid_EB
replace vote_cd_EB = 1 if party_voted_eu_EB == 5 | party_voted_eu_EB == 11

gen vote_so_EB = vote_valid_EB
replace vote_so_EB = 1 if party_voted_eu_EB == 3 | party_voted_eu_EB == 9

gen vote_gr_EB = vote_valid_EB
replace vote_gr_EB = 1 if party_voted_eu_EB == 6 | party_voted_eu_EB == 8

gen vote_li_EB = vote_valid_EB
replace vote_li_EB = 1 if party_voted_eu_EB == 4 | party_voted_eu_EB == 7

gen vote_rl_EB = vote_valid_EB
replace vote_rl_EB = 1 if party_voted_eu_EB == 10

*Merge

gen vote_nva = vote_nva_MA
replace vote_nva = vote_nva_EB if surveyname == "EB2"
label var vote_nva "N-VA"

gen vote_vb = vote_vb_MA
replace vote_vb = vote_vb_EB if surveyname == "EB2"
label var vote_vb "Vlaams Belang"

gen vote_cd = vote_cd_MA
replace vote_cd = vote_cd_EB if surveyname == "EB2"
label var vote_cd "Christian democrats"

gen vote_so = vote_so_MA
replace vote_so = vote_so_EB if surveyname == "EB2"
label var vote_so "Socialists"

gen vote_li = vote_li_MA
replace vote_li = vote_li_EB if surveyname == "EB2"
label var vote_li "Liberals"

gen vote_gr = vote_gr_MA
replace vote_gr = vote_gr_EB if surveyname == "EB2"
label var vote_gr "Greens"

gen vote_rl = vote_rl_MA
replace vote_rl = vote_rl_EB if surveyname == "EB2"
label var vote_rl "Radical left"

***Regressions

logit turnout female##survey_online [pweight=weight]
est store model1
logit turnout c.age##survey_online [pweight=weight]
est store model2
logit turnout c.education##survey_online [pweight=weight]
est store model3
logit turnout c.leftright##survey_online [pweight=weight]
est store model4
logit turnout c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using turnout_be.rtf, pr2 replace
drop _est*

logit vote_cd female##survey_online [pweight=weight]
est store model1
logit vote_cd c.age##survey_online [pweight=weight]
est store model2
logit vote_cd c.education##survey_online [pweight=weight]
est store model3
logit vote_cd c.leftright##survey_online [pweight=weight]
est store model4
logit vote_cd c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using cd_be.rtf, pr2 replace
drop _est*

logit vote_so female##survey_online [pweight=weight]
est store model1
logit vote_so c.age##survey_online [pweight=weight]
est store model2
logit vote_so c.education##survey_online [pweight=weight]
est store model3
logit vote_so c.leftright##survey_online [pweight=weight]
est store model4
logit vote_so c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using so_be.rtf, pr2 replace
drop _est*

logit vote_vb female##survey_online [pweight=weight]
est store model1
logit vote_vb c.age##survey_online [pweight=weight]
est store model2
logit vote_vb c.education##survey_online [pweight=weight]
est store model3
logit vote_vb c.leftright##survey_online [pweight=weight]
est store model4
logit vote_vb c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using vb_be.rtf, pr2 replace
drop _est*

logit vote_nva female##survey_online [pweight=weight]
est store model1
logit vote_nva c.age##survey_online [pweight=weight]
est store model2
logit vote_nva c.education##survey_online [pweight=weight]
est store model3
logit vote_nva c.leftright##survey_online [pweight=weight]
est store model4
logit vote_nva c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using nva_be.rtf, pr2 replace
drop _est*

logit vote_li female##survey_online [pweight=weight]
est store model1
logit vote_li c.age##survey_online [pweight=weight]
est store model2
logit vote_li c.education##survey_online [pweight=weight]
est store model3
logit vote_li c.leftright##survey_online [pweight=weight]
est store model4
logit vote_li c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using li_be.rtf, pr2 replace
drop _est*

logit vote_gr female##survey_online [pweight=weight]
est store model1
logit vote_gr c.age##survey_online [pweight=weight]
est store model2
logit vote_gr c.education##survey_online [pweight=weight]
est store model3
logit vote_gr c.leftright##survey_online [pweight=weight]
est store model4
logit vote_gr c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using gr_be.rtf, pr2 replace
drop _est*

logit vote_rl female##survey_online [pweight=weight]
est store model1
logit vote_rl c.age##survey_online [pweight=weight]
est store model2
logit vote_rl c.education##survey_online [pweight=weight]
est store model3
logit vote_rl c.leftright##survey_online [pweight=weight]
est store model4
logit vote_rl c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using rl_be.rtf, pr2 replace
drop _est*

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\new\elections_belgium.dta", replace

*Germany

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\new\elections.dta"
keep if country == "Germany"

gen survey_online = 0
replace survey_online = 1 if surveyname == "MAPLE2"
label var survey_online "Online survey"

gen turnout_MA = .
replace turnout_MA = 0 if voted_eu_MA > 1 & voted_eu_MA != .
replace turnout_MA = 1 if voted_eu_MA == 1

gen turnout_EB = .
replace turnout_EB = 0 if voted_eu_EB > 1 & voted_eu_EB != .
replace turnout_EB = 1 if voted_eu_EB == 1

gen turnout = turnout_MA
replace turnout = turnout_EB if surveyname == "EB2"
label var turnout "Turnout"

*Maple

gen vote_valid_MA = .
replace vote_valid_MA = 0 if votechoice_eu_MA <= 66

gen vote_cdu_MA = vote_valid_MA
replace vote_cdu_MA = 1 if votechoice_eu_MA == 2

gen vote_spd_MA = vote_valid_MA
replace vote_spd_MA = 1 if votechoice_eu_MA == 8

gen vote_gr_MA = vote_valid_MA
replace vote_gr_MA = 1 if votechoice_eu_MA == 3 

gen vote_afd_MA = vote_valid_MA
replace vote_afd_MA = 1 if votechoice_eu_MA == 1 

gen vote_fdp_MA = vote_valid_MA
replace vote_fdp_MA = 1 if votechoice_eu_MA == 9 

gen vote_li_MA = vote_valid_MA
replace vote_li_MA = 1 if votechoice_eu_MA == 4 

*EB

gen vote_valid_EB = .
replace vote_valid_EB = 0 if party_voted_eu_EB <= 17

gen vote_cdu_EB = vote_valid_EB
replace vote_cdu_EB = 1 if party_voted_eu_EB == 1

gen vote_spd_EB = vote_valid_EB
replace vote_spd_EB = 1 if party_voted_eu_EB == 2

gen vote_gr_EB = vote_valid_EB
replace vote_gr_EB = 1 if party_voted_eu_EB == 3 

gen vote_afd_EB = vote_valid_EB
replace vote_afd_EB = 1 if party_voted_eu_EB == 7 

gen vote_fdp_EB = vote_valid_EB
replace vote_fdp_EB = 1 if party_voted_eu_EB == 5 

gen vote_li_EB = vote_valid_EB
replace vote_li_EB = 1 if party_voted_eu_EB == 4 

*Merge

gen vote_cdu = vote_cdu_MA
replace vote_cdu = vote_cdu_EB if surveyname == "EB2"
label var vote_cdu "CDU/CSU"

gen vote_spd = vote_spd_MA
replace vote_spd = vote_spd_EB if surveyname == "EB2"
label var vote_spd "SPD"

gen vote_gr = vote_gr_MA
replace vote_gr = vote_gr_EB if surveyname == "EB2"
label var vote_gr "Greens"

gen vote_afd = vote_afd_MA
replace vote_afd = vote_afd_EB if surveyname == "EB2"
label var vote_afd "AfD"

gen vote_li = vote_li_MA
replace vote_li = vote_li_EB if surveyname == "EB2"
label var vote_li "Linke"


***Regressions

logit turnout female##survey_online [pweight=weight]
est store model1
logit turnout c.age##survey_online [pweight=weight]
est store model2
logit turnout c.education##survey_online [pweight=weight]
est store model3
logit turnout c.leftright##survey_online [pweight=weight]
est store model4
logit turnout c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using turnout_de.rtf, pr2 replace
drop _est*

logit vote_cdu female##survey_online [pweight=weight]
est store model1
logit vote_cdu c.age##survey_online [pweight=weight]
est store model2
logit vote_cdu c.education##survey_online [pweight=weight]
est store model3
logit vote_cdu c.leftright##survey_online [pweight=weight]
est store model4
logit vote_cdu c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using cdu_de.rtf, pr2 replace
drop _est*

logit vote_spd female##survey_online [pweight=weight]
est store model1
logit vote_spd c.age##survey_online [pweight=weight]
est store model2
logit vote_spd c.education##survey_online [pweight=weight]
est store model3
logit vote_spd c.leftright##survey_online [pweight=weight]
est store model4
logit vote_spd c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using spd_de.rtf, pr2 replace
drop _est*

logit vote_gr female##survey_online [pweight=weight]
est store model1
logit vote_gr c.age##survey_online [pweight=weight]
est store model2
logit vote_gr c.education##survey_online [pweight=weight]
est store model3
logit vote_gr c.leftright##survey_online [pweight=weight]
est store model4
logit vote_gr c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using gr_de.rtf, pr2 replace
drop _est*

logit vote_afd female##survey_online [pweight=weight]
est store model1
logit vote_afd c.age##survey_online [pweight=weight]
est store model2
logit vote_afd c.education##survey_online [pweight=weight]
est store model3
logit vote_afd c.leftright##survey_online [pweight=weight]
est store model4
logit vote_afd c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using afd_de.rtf, pr2 replace
drop _est*

logit vote_li female##survey_online [pweight=weight]
est store model1
logit vote_li c.age##survey_online [pweight=weight]
est store model2
logit vote_li c.education##survey_online [pweight=weight]
est store model3
logit vote_li c.leftright##survey_online [pweight=weight]
est store model4
logit vote_li c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using li_de.rtf, pr2 replace
drop _est*

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\new\elections_germany.dta", replace

*Greece

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\new\elections.dta"
keep if country == "Greece"

gen survey_online = 0
replace survey_online = 1 if surveyname == "MAPLE2"
label var survey_online "Online survey"

gen turnout_MA = .
replace turnout_MA = 0 if voted_eu_MA > 1 & voted_eu_MA != .
replace turnout_MA = 1 if voted_eu_MA == 1

gen turnout_EB = .
replace turnout_EB = 0 if voted_eu_EB > 1 & voted_eu_EB != .
replace turnout_EB = 1 if voted_eu_EB == 1

gen turnout = turnout_MA
replace turnout = turnout_EB if surveyname == "EB2"
label var turnout "Turnout"

*Maple

gen vote_valid_MA = .
replace vote_valid_MA = 0 if votechoice_eu_MA <= 66

gen vote_nd_MA = vote_valid_MA
replace vote_nd_MA = 1 if votechoice_eu_MA == 5

gen vote_sy_MA = vote_valid_MA
replace vote_sy_MA = 1 if votechoice_eu_MA == 9

gen vote_ki_MA = vote_valid_MA
replace vote_ki_MA = 1 if votechoice_eu_MA == 4 

gen vote_kke_MA = vote_valid_MA
replace vote_kke_MA = 1 if votechoice_eu_MA == 2 

gen vote_xa_MA = vote_valid_MA
replace vote_xa_MA = 1 if votechoice_eu_MA == 3 

gen vote_ea_MA = vote_valid_MA
replace vote_ea_MA = 1 if votechoice_eu_MA == 7 

gen vote_me_MA = vote_valid_MA
replace vote_me_MA = 1 if votechoice_eu_MA == 12

*EB

gen vote_valid_EB = .
replace vote_valid_EB = 0 if party_voted_eu_EB <= 17

rename party_voted_eu_EB votechoice_eu_EB

gen vote_nd_EB = vote_valid_EB
replace vote_nd_EB = 1 if votechoice_eu_EB == 1

gen vote_sy_EB = vote_valid_EB
replace vote_sy_EB = 1 if votechoice_eu_EB == 2

gen vote_ki_EB = vote_valid_EB
replace vote_ki_EB = 1 if votechoice_eu_EB == 3 

gen vote_kke_EB = vote_valid_EB
replace vote_kke_EB = 1 if votechoice_eu_EB == 5 

gen vote_xa_EB = vote_valid_EB
replace vote_xa_EB = 1 if votechoice_eu_EB == 4 

gen vote_ea_EB = vote_valid_EB
replace vote_ea_EB = 1 if votechoice_eu_EB == 11 

gen vote_me_EB = vote_valid_EB
replace vote_me_EB = 1 if votechoice_eu_EB == 13

*Merge

gen vote_nd = vote_nd_MA
replace vote_nd = vote_nd_EB if surveyname == "EB2"
label var vote_nd "ND"

gen vote_sy = vote_sy_MA
replace vote_sy = vote_sy_EB if surveyname == "EB2"
label var vote_sy "SYRIZA"

gen vote_ki = vote_ki_MA
replace vote_ki = vote_ki_EB if surveyname == "EB2"
label var vote_ki "KINAL"

gen vote_kke = vote_kke_MA
replace vote_kke = vote_kke_EB if surveyname == "EB2"
label var vote_kke "KKE"

***Regressions

logit turnout female##survey_online [pweight=weight]
est store model1
logit turnout c.age##survey_online [pweight=weight]
est store model2
logit turnout c.education##survey_online [pweight=weight]
est store model3
logit turnout c.leftright##survey_online [pweight=weight]
est store model4
logit turnout c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using turnout_gr.rtf, pr2 replace
drop _est*

logit vote_nd female##survey_online [pweight=weight]
est store model1
logit vote_nd c.age##survey_online [pweight=weight]
est store model2
logit vote_nd c.education##survey_online [pweight=weight]
est store model3
logit vote_nd c.leftright##survey_online [pweight=weight]
est store model4
logit vote_nd c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using nd_gr.rtf, pr2 replace
drop _est*

logit vote_sy female##survey_online [pweight=weight]
est store model1
logit vote_sy c.age##survey_online [pweight=weight]
est store model2
logit vote_sy c.education##survey_online [pweight=weight]
est store model3
logit vote_sy c.leftright##survey_online [pweight=weight]
est store model4
logit vote_sy c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using sy_gr.rtf, pr2 replace
drop _est*

logit vote_ki female##survey_online [pweight=weight]
est store model1
logit vote_ki c.age##survey_online [pweight=weight]
est store model2
logit vote_ki c.education##survey_online [pweight=weight]
est store model3
logit vote_ki c.leftright##survey_online [pweight=weight]
est store model4
logit vote_ki c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using ki_gr.rtf, pr2 replace
drop _est*

logit vote_kke female##survey_online [pweight=weight]
est store model1
logit vote_kke c.age##survey_online [pweight=weight]
est store model2
logit vote_kke c.education##survey_online [pweight=weight]
est store model3
logit vote_kke c.leftright##survey_online [pweight=weight]
est store model4
logit vote_kke c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using kke_gr.rtf, pr2 replace
drop _est*

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\new\elections_greece.dta", replace

*Ireland

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\new\elections.dta"
keep if country == "Ireland"

gen survey_online = 0
replace survey_online = 1 if surveyname == "MAPLE2"
label var survey_online "Online survey"

gen turnout_MA = .
replace turnout_MA = 0 if voted_eu_MA > 1 & voted_eu_MA != .
replace turnout_MA = 1 if voted_eu_MA == 1

gen turnout_EB = .
replace turnout_EB = 0 if voted_eu_EB > 1 & voted_eu_EB != .
replace turnout_EB = 1 if voted_eu_EB == 1

gen turnout = turnout_MA
replace turnout = turnout_EB if surveyname == "EB2"
label var turnout "Turnout"

*Maple

gen vote_valid_MA = .
replace vote_valid_MA = 0 if votechoice_eu_MA <= 66

gen vote_fg_MA = vote_valid_MA
replace vote_fg_MA = 1 if votechoice_eu_MA == 2

gen vote_ff_MA = vote_valid_MA
replace vote_ff_MA = 1 if votechoice_eu_MA == 1

gen vote_ind_MA = vote_valid_MA
replace vote_ind_MA = 1 if votechoice_eu_MA == 8 |  votechoice_eu_MA == 9 | votechoice_eu_MA == 10 

gen vote_sf_MA = vote_valid_MA
replace vote_sf_MA = 1 if votechoice_eu_MA == 4 

gen vote_gp_MA = vote_valid_MA
replace vote_gp_MA = 1 if votechoice_eu_MA == 5  

gen vote_la_MA = vote_valid_MA
replace vote_la_MA = 1 if votechoice_eu_MA == 3

*EB

gen vote_valid_EB = .
replace vote_valid_EB = 0 if party_voted_eu_EB <= 17

rename party_voted_eu_EB votechoice_eu_EB

gen vote_fg_EB = vote_valid_EB
replace vote_fg_EB = 1 if votechoice_eu_EB == 1

gen vote_ff_EB = vote_valid_EB
replace vote_ff_EB = 1 if votechoice_eu_EB == 2

gen vote_ind_EB = vote_valid_EB
replace vote_ind_EB = 1 if votechoice_eu_EB == 5 

gen vote_sf_EB = vote_valid_EB
replace vote_sf_EB = 1 if votechoice_eu_EB == 3 

gen vote_gp_EB = vote_valid_EB
replace vote_gp_EB = 1 if votechoice_eu_EB == 7 

gen vote_la_EB = vote_valid_EB
replace vote_la_EB = 1 if votechoice_eu_EB == 4

*Merge

gen vote_fg = vote_fg_MA
replace vote_fg = vote_fg_EB if surveyname == "EB2"
label var vote_fg "Fine Gael"

gen vote_ff = vote_ff_MA
replace vote_ff = vote_ff_EB if surveyname == "EB2"
label var vote_ff "Fianna Fáil"

gen vote_ind = vote_ind_MA
replace vote_ind = vote_ind_EB if surveyname == "EB2"
label var vote_ind "Independents"

gen vote_sf = vote_sf_MA
replace vote_sf = vote_sf_EB if surveyname == "EB2"
label var vote_sf "Sinn Féin"

gen vote_gp = vote_gp_MA
replace vote_gp = vote_gp_EB if surveyname == "EB2"
label var vote_gp "Greens"

***Regressions

logit turnout female##survey_online [pweight=weight]
est store model1
logit turnout c.age##survey_online [pweight=weight]
est store model2
logit turnout c.education##survey_online [pweight=weight]
est store model3
logit turnout c.leftright##survey_online [pweight=weight]
est store model4
logit turnout c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using turnout_ie.rtf, pr2 replace
drop _est*

logit vote_fg female##survey_online [pweight=weight]
est store model1
logit vote_fg c.age##survey_online [pweight=weight]
est store model2
logit vote_fg c.education##survey_online [pweight=weight]
est store model3
logit vote_fg c.leftright##survey_online [pweight=weight]
est store model4
logit vote_fg c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using fg_ie.rtf, pr2 replace
drop _est*

logit vote_ff female##survey_online [pweight=weight]
est store model1
logit vote_ff c.age##survey_online [pweight=weight]
est store model2
logit vote_ff c.education##survey_online [pweight=weight]
est store model3
logit vote_ff c.leftright##survey_online [pweight=weight]
est store model4
logit vote_ff c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using ff_ie.rtf, pr2 replace
drop _est*

logit vote_sf female##survey_online [pweight=weight]
est store model1
logit vote_sf c.age##survey_online [pweight=weight]
est store model2
logit vote_sf c.education##survey_online [pweight=weight]
est store model3
logit vote_sf c.leftright##survey_online [pweight=weight]
est store model4
logit vote_sf c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using sf_ie.rtf, pr2 replace
drop _est*

logit vote_gp female##survey_online [pweight=weight]
est store model1
logit vote_gp c.age##survey_online [pweight=weight]
est store model2
logit vote_gp c.education##survey_online [pweight=weight]
est store model3
logit vote_gp c.leftright##survey_online [pweight=weight]
est store model4
logit vote_gp c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using gp_ie.rtf, pr2 replace
drop _est*

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\new\elections_ireland.dta", replace

*Portugal

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\new\elections.dta"
keep if country == "Portugal"

gen survey_online = 0
replace survey_online = 1 if surveyname == "MAPLE2"
label var survey_online "Online survey"

gen turnout_MA = .
replace turnout_MA = 0 if voted_eu_MA > 1 & voted_eu_MA != .
replace turnout_MA = 1 if voted_eu_MA == 1

gen turnout_EB = .
replace turnout_EB = 0 if voted_eu_EB > 1 & voted_eu_EB != .
replace turnout_EB = 1 if voted_eu_EB == 1

gen turnout = turnout_MA
replace turnout = turnout_EB if surveyname == "EB2"
label var turnout "Turnout"

*Maple

gen vote_valid_MA = .
replace vote_valid_MA = 0 if votechoice_eu_MA <= 66

gen vote_ps_MA = vote_valid_MA
replace vote_ps_MA = 1 if votechoice_eu_MA == 9

gen vote_psd_MA = vote_valid_MA
replace vote_psd_MA = 1 if votechoice_eu_MA == 5

gen vote_be_MA = vote_valid_MA
replace vote_be_MA = 1 if votechoice_eu_MA == 1 

gen vote_cdu_MA = vote_valid_MA
replace vote_cdu_MA = 1 if votechoice_eu_MA == 2 

gen vote_cds_MA = vote_valid_MA
replace vote_cds_MA = 1 if votechoice_eu_MA == 4  

gen vote_pan_MA = vote_valid_MA
replace vote_pan_MA = 1 if votechoice_eu_MA == 8

*EB

gen vote_valid_EB = .
replace vote_valid_EB = 0 if party_voted_eu_EB <= 17

rename party_voted_eu_EB votechoice_eu_EB

gen vote_ps_EB = vote_valid_EB
replace vote_ps_EB = 1 if votechoice_eu_EB == 1

gen vote_psd_EB = vote_valid_EB
replace vote_psd_EB = 1 if votechoice_eu_EB == 2

gen vote_be_EB = vote_valid_EB
replace vote_be_EB = 1 if votechoice_eu_EB == 3 

gen vote_cdu_EB = vote_valid_EB
replace vote_cdu_EB = 1 if votechoice_eu_EB == 4 

gen vote_cds_EB = vote_valid_EB
replace vote_cds_EB = 1 if votechoice_eu_EB == 5  

gen vote_pan_EB = vote_valid_EB
replace vote_pan_EB = 1 if votechoice_eu_EB == 6

*Merge

gen vote_ps = vote_ps_MA
replace vote_ps = vote_ps_EB if surveyname == "EB2"
label var vote_ps "PS"

gen vote_psd = vote_psd_MA
replace vote_psd = vote_psd_EB if surveyname == "EB2"
label var vote_psd "PSD"

gen vote_be = vote_be_MA
replace vote_be = vote_be_EB if surveyname == "EB2"
label var vote_be "BE"

***Regressions

logit turnout female##survey_online [pweight=weight]
est store model1
logit turnout c.age##survey_online [pweight=weight]
est store model2
logit turnout c.education##survey_online [pweight=weight]
est store model3
logit turnout c.leftright##survey_online [pweight=weight]
est store model4
logit turnout c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using turnout_pt.rtf, pr2 replace
drop _est*

logit vote_psd female##survey_online [pweight=weight]
est store model1
logit vote_psd c.age##survey_online [pweight=weight]
est store model2
logit vote_psd c.education##survey_online [pweight=weight]
est store model3
logit vote_psd c.leftright##survey_online [pweight=weight]
est store model4
logit vote_psd c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using psd_pt.rtf, pr2 replace
drop _est*

logit vote_ps  female##survey_online [pweight=weight]
est store model1
logit vote_ps  c.age##survey_online [pweight=weight]
est store model2
logit vote_ps  c.education##survey_online [pweight=weight]
est store model3
logit vote_ps  c.leftright##survey_online [pweight=weight]
est store model4
logit vote_ps  c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using ps_pt.rtf, pr2 replace
drop _est*

logit vote_be  female##survey_online [pweight=weight]
est store model1
logit vote_be  c.age##survey_online [pweight=weight]
est store model2
logit vote_be  c.education##survey_online [pweight=weight]
est store model3
logit vote_be  c.leftright##survey_online [pweight=weight]
est store model4
logit vote_be  c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using be_pt.rtf, pr2 replace
drop _est*

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\new\elections_portugal.dta", replace

*Spain

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\new\elections.dta"
keep if country == "Spain"

gen survey_online = 0
replace survey_online = 1 if surveyname == "MAPLE2"
label var survey_online "Online survey"

gen turnout_MA = .
replace turnout_MA = 0 if voted_eu_MA > 1 & voted_eu_MA != .
replace turnout_MA = 1 if voted_eu_MA == 1

gen turnout_EB = .
replace turnout_EB = 0 if voted_eu_EB > 1 & voted_eu_EB != .
replace turnout_EB = 1 if voted_eu_EB == 1

gen turnout = turnout_MA
replace turnout = turnout_EB if surveyname == "EB2"
label var turnout "Turnout"

*Maple

gen vote_valid_MA = .
replace vote_valid_MA = 0 if votechoice_eu_MA <= 66

gen vote_ps_MA = vote_valid_MA
replace vote_ps_MA = 1 if votechoice_eu_MA == 2

gen vote_pp_MA = vote_valid_MA
replace vote_pp_MA = 1 if votechoice_eu_MA == 4

gen vote_cs_MA = vote_valid_MA
replace vote_cs_MA = 1 if votechoice_eu_MA == 1 

gen vote_po_MA = vote_valid_MA
replace vote_po_MA = 1 if votechoice_eu_MA == 5 

gen vote_vox_MA = vote_valid_MA
replace vote_vox_MA = 1 if votechoice_eu_MA == 10  

*EB

gen vote_valid_EB = .
replace vote_valid_EB = 0 if party_voted_eu_EB <= 17

rename party_voted_eu_EB votechoice_eu_EB

gen vote_ps_EB = vote_valid_EB
replace vote_ps_EB = 1 if votechoice_eu_EB == 3

gen vote_pp_EB = vote_valid_EB
replace vote_pp_EB = 1 if votechoice_eu_EB == 2

gen vote_cs_EB = vote_valid_EB
replace vote_cs_EB = 1 if votechoice_eu_EB == 1 

gen vote_po_EB = vote_valid_EB
replace vote_po_EB = 1 if votechoice_eu_EB == 4 

gen vote_vox_EB = vote_valid_EB
replace vote_vox_EB = 1 if votechoice_eu_EB == 10  

*Merge

gen vote_ps = vote_ps_MA
replace vote_ps = vote_ps_EB if surveyname == "EB2"
label var vote_ps "PSOE"

gen vote_pp = vote_pp_MA
replace vote_pp = vote_pp_EB if surveyname == "EB2"
label var vote_pp "PP"

gen vote_cs = vote_cs_MA
replace vote_cs = vote_cs_EB if surveyname == "EB2"
label var vote_cs "Ciudadanos"

gen vote_po = vote_po_MA
replace vote_po = vote_po_EB if surveyname == "EB2"
label var vote_po "Unidas Podemos"

***Regressions

logit turnout female##survey_online [pweight=weight]
est store model1
logit turnout c.age##survey_online [pweight=weight]
est store model2
logit turnout c.education##survey_online [pweight=weight]
est store model3
logit turnout c.leftright##survey_online [pweight=weight]
est store model4
logit turnout c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using turnout_es.rtf, pr2 replace
drop _est*

logit vote_pp female##survey_online [pweight=weight]
est store model1
logit vote_pp c.age##survey_online [pweight=weight]
est store model2
logit vote_pp c.education##survey_online [pweight=weight]
est store model3
logit vote_pp c.leftright##survey_online [pweight=weight]
est store model4
logit vote_pp c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using pp_es.rtf, pr2 replace
drop _est*

logit vote_ps  female##survey_online [pweight=weight]
est store model1
logit vote_ps  c.age##survey_online [pweight=weight]
est store model2
logit vote_ps  c.education##survey_online [pweight=weight]
est store model3
logit vote_ps  c.leftright##survey_online [pweight=weight]
est store model4
logit vote_ps  c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using ps_es.rtf, pr2 replace
drop _est*

logit vote_cs  female##survey_online [pweight=weight]
est store model1
logit vote_cs  c.age##survey_online [pweight=weight]
est store model2
logit vote_cs  c.education##survey_online [pweight=weight]
est store model3
logit vote_cs  c.leftright##survey_online [pweight=weight]
est store model4
logit vote_cs  c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using ciu_es.rtf, pr2 replace
drop _est*

logit vote_po  female##survey_online [pweight=weight]
est store model1
logit vote_po  c.age##survey_online [pweight=weight]
est store model2
logit vote_po  c.education##survey_online [pweight=weight]
est store model3
logit vote_po  c.leftright##survey_online [pweight=weight]
est store model4
logit vote_po  c.econ_eval##survey_online [pweight=weight]
est store model5
 
esttab model1 model2 model3 model4 model5 using po_es.rtf, pr2 replace
drop _est*

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\new\elections_spain.dta", replace
